function ping_machine(img) {
  var id = img.id.substring(4);
  img.src = "/img/busy.gif";
  $.ajax({
    url: "/machines/ping/" + id + "/",
    cache: false,
    success: function(response){
    	if (eval(response)) {
    		img.src = "/img/up.gif";
    	}
    	else {
    		img.src = "/img/down.gif";
    	}
    }});
}

function ping_machines() {
  $("img.pingmachine").each(function(i) {
    ping_machine(this);
  });
}

$(document).ready(function() {
  ping_machines();
  var redo = 60000; /* Every 1 minute */
  setInterval('ping_machines();', redo);
});
